package com.example.design.bilibili.flyweight;

/**
 * 享元模式
 */
public class Client {

    public static void main(String[] args) {

        //创建一个工厂类，
        WebSiteFactory factory = new WebSiteFactory();

        //客户要一个以新闻形式发布的网站
        WebSite webSite1 = factory.getWebSiteCategory("新闻");
        webSite1.use(new User("xiaoming"));

        //客户要一个以博客形式发布的网站
        WebSite webSite2 = factory.getWebSiteCategory("博客");
        webSite2.use(new User("David"));

        //客户要一个以博客形式发布的网站
        WebSite webSite3 = factory.getWebSiteCategory("博客");
        webSite3.use(new User("Lili"));

        //客户要一个以微信企业好形式发布的网站
        WebSite webSite4 = factory.getWebSiteCategory("微信企业好");
        webSite4.use(new User("Lucy"));

        System.out.println("网站的分类共"+factory.getWebSiteCount());
    }
}
